#pragma once

#include "common.h"

// 单例模式
class CentralCache
{
public:
    static CentralCache *GetInstance()
    {
        return &_sInst; 
    }
    // 从中心缓存获取一批内存给thread cache
    size_t FetRangeObj(void*& start, void*& end, size_t batchNum, size_t size);

    // 获取一个非空的span
    Span *GetOneSpan(SpanList &list, size_t size);

    void ReleaseListToSpans(void* start, size_t size);

private:
    SpanList _spanList[NFREE_LIST];

private:
    CentralCache()
    {}
    CentralCache(const CentralCache&) = delete;
    static CentralCache _sInst;
};